Introduction

ShinyBaseball is an R package containing several Shiny apps to illustrate Statcast baseball data. This document provides an overview of the Shiny functions available in ShinyBaseball version 0.2.7.

Learning Shiny Apps

There are several apps demonstrating some interactive graphics features of Shiny.

PointBrush()

This app illustrates scatterplot brushing. One can select X and Y variables to graph. One selects a region of interest and the app will display the names, x and y variables for the points in the region.

PointClick() and PointHover()

These apps illustrating clicking and hovering capabilities of Shiny graphics. Again one selects variables to graph. By clicking or hovering near a point, the app will display the name and X and Y variables for that point.

Batting and Pitching Apps

FourMeasures()

This is useful for exploring relationships between four variables in the FanGraphs batting leaderboard. One selects X1, Y1, X2, Y2 variables to graph. One sees two scatterplots. One can brush either scatterplot - the corresponding points in the other scatterplot are colored red. Also the app displays the names and variables corresponding to the points in the brushed region.

PitchOutcome()

This app is helpful for visualizing pitch outcomes for any pitcher or batter of interest.

We indicate by use of the Player Type button if we want to look at pitching or batting data. Then we enter in the Player Name and the Pitch Type of interest.

Here we indicate that we wish to look at a Pitcher, enter in Jacob DeGrom’s name, and select “FF” from the Pitch Type pallet.

We see the locations of All of Jacob DeGrom’s four-seamers where the color of the point corresponds to the Type variable (ball, strike, or inplay).

By selecting “Called” from the Pitches to Display pallet, we see the locations of all Called pitches where the color corresponds to called ball or called strike.

By selecting “Swing” from the Pitches to Display pallet, we see the locations of all swung pitches – the color of the point corresponds to the outcome (foul, inplay or miss). One can brush over this scatterplot – the app displays the number of swung pitches and miss rate for the points in the brushed region.

By selecting “In-Play” from the Pitches to Display pallet, we see the locations of all pitches put in-play – the color of the point corresponds to the outcome (hit or out). One can brush over this scatterplot – the app displays the number of pitches in-play and hit rate for the points in the brushed region.

PitchTypeCount()

This app is helpful for comparing pitch locations across pitch types and counts.

We enter in the Pitcher Name (here Jacob DeGrom). By selecting “FF” and “SL” from the Pitch Type pallet and “0-0” from the Count pallet, we can compare locations of four-seamers and sliders on a 0-0 count.

By selecting “FF” and “SL” from the Pitch Type pallet and “2-0”, “1-1” and “0-2” from the Count pallet, we can compare locations of four-seamers and sliders on these three “2 pitch” counts.

BrushingZone()

This app is a general function for plotting and brushing different measures on balls put in-play over the zone.

We begin by entering in a batter’s name – here we enter Bryce Harper.

We see the locations of all pitches put in play where the color of the point corresponds to the launch speed.

If one clicks on an individual point, you will see the launch speed, launch angle and expected batting average for that ball put into play.

If one brushes over this plot, the app displays number of balls in play (BIP), the number of hits (H) and home runs (HR), and the average values of launch speed, hit rate, home run rate and expected BA for points in the brushed region.

If one selects Home Run, the points are colored by the outcome (home run or not).

This app can also be used to show locations of hits or expected batting average over the zone.

Datasets

All of the data for using these apps is included as part of the ShinyBaseball package.

chadwick

This provides the Statcast ids for all Major League Players.

fg2020batting

This dataset contains stats for the FanGraphs leaders for the 2020 season. This data is used for the FourMeasures(), PointBrush(), PointClick(), PointHover() Shiny apps.

sc2019_ip

This dataset provides Statcast data for the 125,751 balls put in play for the 2019 season. This data is used for the BrushingZone() Shiny app.

sc_pitcher_2019

This dataset provides Statcast data for the 732,473 pitches in the 2019 season. This is data is used for the PitchOutcome() and PitchTypeCount() Shiny apps.